<script type="text/javascript">	
	$(document).ready(function(){ 
		$("#save").click(function(){
			if(($('#newpword').val() == $('#newpword_con').val() && $('#newpword').val().length > 0 && $('#oldpword').val().length > 0 ) || ($('#newpword').val().length == 0 && $('#newpword_con').val().length == 0 && $('#oldpword').val().length == 0)){
				$.get('ajax/registration/save.php', {
														email: $('#email').val(),
														rname: $('#rname').val(),
														newpword: $('#newpword').val(),
														oldpword: $('#oldpword').val(),
														avatar: $('#avatar').val(),
													}, function(data){
														
														if(data == ""){
															alert("profile updated");
														} else {
															alert(data);
														}
														fetchPage('profile');	
													});
									  
				
			}
		});
	});
</script>

<h2>{{profileTitle}}</h2>

<p>

<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="25%"><strong>Username</strong></td>
    <td width="25%">{{username}}</td>
    <td width="50%">&nbsp;</td>
  </tr>
  <tr>
    <td><strong>Email</strong></td>
    <td><input id="email" name="email" type="text" value="{{email}}" style="width:200px;" /></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td><strong>Your name</strong></td>
    <td><input id="rname" name="rname" type="text" value="{{rname}}" style="width:200px;" /></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td><strong>Your avatar url</strong></td>
    <td><input id="avatar" name="avatar" type="text" value="{{avatar}}" style="width:400px;" /></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td id="no_border">&nbsp;</td>
    <td id="no_border">&nbsp;</td>
    <td id="no_border">&nbsp;</td>
  </tr>
  <tr>
    <td>New password</td>
    <td><input id="newpword" name="newpword" type="password" style="width:200px;" /></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>Confirm New password</td>
    <td><input id="newpword_con" name="newpword_con" type="password" style="width:200px;" /></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>Current password</td>
    <td><input id="oldpword" name="oldpword" type="password" style="width:200px;" /></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td id="no_border">&nbsp;</td>
    <td id="no_border"><input id="save" name="save" type="button" value="save" /></td>
    <td id="no_border">&nbsp;</td>
  </tr>
</table>

</p>
